<?php
$this->layout("blog/base", $this->data);


if ($err) {
    $this->start("container");
    echo $err;
    $this->stop();
} else {
    $this->start("container");
    $clicks = number_format($art['clicks']);
    $nickname=getnickname($art['adminuid']);
    ?>
    <style>
        .main-wrapper .container, .single-col-max-width {
            max-width: unset;
        }

        .blog-post-header .btn {
            height: unset;
        }

        .blog-post-header .btn-min {
            font-size: 0.5rem;
            padding: 0.1rem 0.5rem;
            font-weight: normal;
        }
    </style>
    <header class="blog-post-header">
        <h2 class="title mb-1"><?php if ($art['top']): ?><span
                    style="color: #cc0000">[置顶]</span><?php endif; ?> <?= $this->e($art['title']) ?></h2>
        <div class="meta mb-1">
            <span title="发布时间：<?php echo time_format($art['posttime']); ?>" class="date"
                  style="cursor:help;text-decoration: underline dotted">发布于 <?php echo humanizer_datetime($art['posttime']); ?></span>
            <?php
            if (humanizer_datetime($art['posttime']) != humanizer_datetime($art['modify'])): ?>
                <span title="修改时间：<?php echo time_format($art['modify']); ?>" class="date"
                      style="cursor:help;text-decoration: underline dotted">修改于 <?php echo humanizer_datetime($art['modify']); ?></span>
            <?php endif; ?>
            <span class="time"><?= $clicks ?> 次浏览</span>
            <?php if ($show_article_guestbook): ?>
                <span class="text-link"><a class="text-link" href="#guestbook"><?= $message_cout ?> 条留言</a></span>
            <?php endif; ?>
            <span class=""><a class="" target="_blank" href="/blog/s-AUTHOR:<?=$art['adminuid'].':'.$nickname?>"><?=$nickname?></a></span>
        </div>
        <div class="mb-1"><?= $tags ?></div>
    </header>

    <div class="blog-post-body">
        <?php echo md($art['content']) ?>
    </div>
    <div class="blog-post-footer">
        <?php if ($show_article_guestbook): ?>
            <hr>
            <div id="guestbook" class="cta-section theme-bg-light py-1">
                <div class="container single-col-max-width">
                    <h3 style="text-align: center" class="mb-3">留言列表</h3>
                    <?php foreach ($postmessages as $m): ?>
                        <div class="mb-4 mt-4">
                            <div><span class="badge text-bg-danger"><?php if ($m['top']) echo '[置顶]'; ?></span>
                                <b><?= $this->e($m['nickname']) ?></b> <span
                                        title="<?php echo time_format($m['posttime']) ?>"
                                        class="text-info"><?= humanizer_datetime($m['posttime']) ?></span> ：
                            </div>
                            <div style="padding-left: 2rem"><?= $this->e($m['message']) ?></div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>

        <?php endif; ?>
        <?php if ($open_article_guestbook): ?>
            <hr>
            <div class="cta-section theme-bg-light py-1">
                <div class="container text-center single-col-max-width">
                    <div class="single-form-max-width pt-3 mx-auto">
                        <h3 class="mb-3">文章留言</h3>
                        <form class="signup-form row g-2 g-lg-2 align-items-center" method="post"
                              action="/blog/guestbook_post">
                            <input type="hidden" value="<?php echo getRequestUri() ?>" name="posturl">
                            <input type="hidden" value="<?= $this->e($art['id']) ?>" name="postid">
                            <div class="form-floating">
                                <input required value="<?php echo session_get('email', '') ?>" type="email" name="email"
                                       class="form-control" id="floatingInput" placeholder="电子邮箱">
                                <label for="floatingInput">电子邮箱</label>
                            </div>
                            <div class="form-floating">
                                <input required value="<?php echo session_get('nickname', '') ?>" type="text"
                                       name="nickname" class="form-control" id="floatingnickname" placeholder="昵称">
                                <label for="floatingnickname">昵称</label>
                            </div>
                            <div class="form-floating">
                                <input required value="<?php echo session_get('message', '') ?>" type="text"
                                       name="message" class="form-control" id="floatingmessage" placeholder="一句话">
                                <label for="floatingmessage">一句话</label>
                            </div>
                            <div>
                                <button style="width: 100%" type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        <?php endif; ?>
    </div>
    <?php
    $this->stop();
}